<{include file="OA/cooperation/header.tpl"}>
	<section id="spread_one" class="column">
		
        <{if $alert_message}>
		<h4 class="alert_info"><{$alert_message}></h4>
        <{/if}>
		

		<article class="module width_3_quarter">
		<header>
			<h3 class="tabs_involved "><{if $method=="add_submit"}>添加新的公司<{else}>修改公司信息<{/if}></h3>
		</header>
		<form action="<{$method}>" method='post' id="add_developer">
		<div class="tab_container">
			<div id="tab1" class="tab_content">
			<table class="tablesorter dev-edit" cellspacing="0"> 
			<tbody> 
				<tr> 
   					<td><label class="l01">公司名称</label><input type="text" class="name" name="name" size="24" value="<{$detail.name}>"> 
					</td> 
   					<td><label class="l01">联系电话</label><input type="text" class="phone" name="phone" size="24" value="<{$detail.phone}>"> 
					</td> 
				</tr> 
				<tr> 
   					<td><label class="l01">公司地址</label><input type="text" class="address" name="address" size="24" value="<{$detail.address}>"> 
					</td> 
   					<td><label class="l01">公司主页</label><input type="text" class="homepage" name="homepage" size="24" value="<{$detail.homepage}>"> 
					</td> 
				</tr> 
				<tr> 
   					<td><label class="l01">开户银行</label><input type="text" class="bankname" name="bankname" size="24" value="<{$detail.bank.bank_name}>"> 
					</td> 
   					<td><label class="l01">开户人姓名</label><input type="text" class="accountname" name="accountname" size="24" value="<{$detail.bank.account_name}>"> 
					</td> 
				</tr> 
				<tr> 
   					<td><label class="l01">开户帐号</label><input type="text" class="account" name="account" size="24" value="<{$detail.bank.account_no}>"> 
					</td> 
   					<td><label class="l01">备注</label><input type="text" class="comments" name="comments" size="24" value="<{$detail.comments}>"> 
					</td> 
				</tr> 
				<{if $method == 'add_submit'}>
				<tr>
					<td colspan="2" style="text-align:center;width:100%">
					<hr>
					</td>
				</tr>
				<tr> 
   					<td align="center"><h3>商务联系人</h3> 
					</td> 
   					<td><label class="l01">姓名</label><input type="text" class="business_name" name="business_name" size="24" value="<{$detail.comments}>"> 
					</td> 
				</tr> 
				<tr>
                    <td>
                        <label class="l01">职位</label><input type="text" name="business_job" value="<{$contact.job}>"size="24">
                    </td>
                    <td>
                        <label class="l01">所属部门</label><input type="text"  name="business_department" value="<{$contact.department}>"size="24">
                    </td>
                </tr>
                 <tr>
                    <td>
                        <label class="l01">移动电话</label><input type="text" name="business_mobilephone" value="<{$contact.mobile}>"size="24">
                    </td>
                    <td>
                        <label class="l01">固定电话</label><input type="text"  name="business_phone" value="<{$contact.phone}>"size="24">
                    </td>
                </tr>
                 <tr>
                    <td>
                        <label class="l01">QQ</label><input type="text" name="business_qq" value="<{$contact.qq}>"size="24">
                    </td>
                    <td>
                        <label class="l01">mail</label><input type="text" class="mail" name="business_mail" value="<{$contact.email}>" size="24">
                    </td>
                </tr>
				<tr>
					<td colspan="2" style="text-align:center;width:100%">
					<hr>
					</td>
				</tr>
				<tr>
                    <td align="center"><h3>结算联系人</h3>
                    </td>
                    <td><label class="l01">姓名</label><input type="text" class="payment_name" name="payment_name" size="24" value="<{$detail.comments}>">
                    </td>
                </tr>
                <tr>
                    <td>
                        <label class="l01">职位</label><input type="text" name="payment_job" value="<{$contact.job}>"size="24">
                    </td>
                    <td>
                        <label class="l01">所属部门</label><input type="text"  name="payment_department" value="<{$contact.department}>"size="24">
                    </td>
                </tr>
                 <tr>
                    <td>
                        <label class="l01">移动电话</label><input type="text" name="payment_mobilephone" value="<{$contact.mobile}>"size="24">
                    </td>
                    <td>
                        <label class="l01">固定电话</label><input type="text"  name="payment_phone" value="<{$contact.phone}>"size="24">
                    </td>
                </tr>
                 <tr>
                    <td>
                        <label class="l01">QQ</label><input type="text" name="payment_qq" value="<{$contact.qq}>"size="24">
                    </td>
                    <td>
                        <label class="l01">mail</label><input type="text" class="mail" name="payment_mail" value="<{$contact.email}>" size="24">
                    </td>
                </tr>
				<tr>
					<td colspan="2" style="text-align:center;width:100%">
					<hr>
					</td>
				</tr>
				<tr>
                    <td><label class="l01">合作包包名</label><input type="text" class="package_name" name="packagename" size="24">
                    </td>
                    <td>
                        <span class="package_icon_url"></span>
                        <span class="apk_name"></span>
						<input type="hidden" name="apk_name" class="input_apk_name">
                    </td>
                </tr>
				<tr>
                    <td>
                       <label class="l01">支付方式</label>
                        <select name='pay_type'>
                            <{foreach from="$pay_type" item=v}>
                                 <option value ="<{$v.id}>"><{$v.name}></option>
                            <{/foreach}>
                        </select>
                    </td>
                    <td>
                        <label class="l01">cp分成比例</label><input type="text" class="ratio" name="ratio" size="4" >%
                    </td>
                </tr>
				<tr>
                    <td>
                        <label class="l01">合作开始时间</label><input type="text" value="<{$start_date}>" id="date1" name='start_time' />
                    </td>
                    <td>
                        <label class="l01">合作结束时间</label><input type="text" value="2099/12/31" id="date1" name='end_time' />
                    </td>
                </tr>
				<tr>
					<td><label class="l01">税费比例</label> <input type="text" name="cost_ratio" value="8" size="4">%</td>
					<td style="text-align:left">
						<input type="submit" class="bulid_action fw spread_submit" value="提交">
					</td>
				</tr>
				<{else}>
				<tr>
                    <td colspan="2" style="text-align:center">
                        <input type="submit" class="bulid_action fw spread_submit" value="修改">
                    </td>
                </tr>
				<{/if}>
			</tbody> 
			</table>
			</div><!-- end of #tab1 -->
		</div><!-- end of .tab_container -->
		</form>	
		</article><!-- end of content manager article -->
		<div class="clear"></div>
	</section>
	<script>
		$('.package_name').blur(function () {
            var package_name  = $('.package_name').val();
            $.get('../apk/apk_info?package_name=' + package_name, {} ,function (data) {
                    if(data.name){
                        $('.package_icon_url').html('<img src="'+data.iconUrl+'">');
                        $('.apk_name').html('<p>'+ data.name +'</p>');
                        $('.input_apk_name').val(data.name);
                    }else{
                        $('.apk_name').html('<p>包名不合法</p>');
                        $('.input_apk_name').val('error_pkg');
                    }
            } , 'json');
        });
		$('#add_developer').submit(function() {
			// form validation.
			if ($('.name').val() == '')
			{
				alert('必须添加一个公司');
                return false;
			}
			if ($('.payment_name').val() == '' && $('.business_name').val() == '')
			{
				alert('结算联系人和商务联系人至少添加一个');
				return false;
			}
			if ($('.package_name').val() == '')
			{
				alert('必须添加一个包');
                return false;
			}
			if ($('.input_apk_name').val() == 'error_pkg')
			{
				alert('添加的包不合法');
				return false;
			}
			return confirm('确定此次操作么？');
		});
	</script>
<{include file="OA/cooperation/footer.tpl"}>
